<template>
	<h1>退出登录</h1>
	<p>{{ `${remainingTime}秒后跳转到登录页面` }}</p>
</template>

<script setup>
import simpleRequest from '@/utils/requestUtils.js'
import Api from '@/api'
import { onMounted, ref } from 'vue'
import useStore from '@/store'
import router from '@/router'


const { userStore } = useStore()

const remainingTime = ref(3)
const startCountdown = () => {
	const intervalId = setInterval(() => {
		remainingTime.value -= 1
		if (remainingTime.value <= 0) {
			clearInterval(intervalId)
			router.push('/auth')
		}
	}, 1000)
}

onMounted(() => {
	simpleRequest(Api.logout, null, () => {
			userStore.$reset()
			startCountdown()
		}
		, '退出成功', '退出失败')
})
</script>


<style scoped>

</style>